package com.springboot.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.springboot.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author gali
 * @description:
 * @date 2022/6/21 10:31
 */
@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {

    /**
     * 获取用户信息
     * @param username
     * @return
     */
    @Select("select * from user where username = #{username}")
    User getUserInfo(String username);

    /**
     * 插入用户信息
     * @param username
     * @param password
     * @param role
     * @return
     */
    @Insert("insert into user(username,password,role) value(#{username},#{password},#{role}) ")
    int  insertUser(String username,String password,String role);

    /**
     * 更新用户密码
     * @param username
     * @param newPwd
     * @return
     */
    @Update("update user set password=#{password} where username=#{username}")
    int updatePwd(String username ,String newPwd);
}
